****************************************************************************************************************************************************************
*REPLICATION MATERIAL FOR
*Rudolph, L., Kolcava, D., & Bernauer, T.
*Public demand for extraterritorial environmental and social public goods provision
*
*Forthcoming in British Journal of Political Science
*
*2022-03-30
*
*Version 1.0, by Lukas Rudolph
****************************************************************************************************************************************************************
/*
Dataset used: master.dta
*/
****************************************************************************************************************************************************************

****************************************************************************************************************************************************************
*This Do-File replicates the results presented in
/*
Figure 2: 		AMCEs of conjoint choice experiment for dimensions stringency and reciprocity
Figure 3:		Respondent evaluations of regulatory frameworks by policy components for subgroups not receiving the norms-treatment
Figure 4:		AMCEs for conjoint choice by subgroups of environmental and social concern
Figure 5:		Marginal means of conjoint choice experiment for dimensions stringency and reciprocity 

Table A.1:		Effect of norm treatment on mechanisms

Figure A.4:		Marginal means of consequences of policy vignette for dimensions stringency and reciprocity with 95% confidence intervals (robust standard errors in parentheses) by norms treatment
Figure A.5:		Subgroups effects for conjoint choice by environmental and social concern and by respondents not receiving (upper panel) and receiving (lower panel) the norms treatment
Figure A.6:		Marginal means for the rating task of conjoint experiment for two dimensions stringency (top) and reciprocity (bottom) by norms treatment
*/
************************************************************************************************************************************************************************************************************************

****************************************************************************************************************************************************************
*prepare Stata

version 14 
set more off
clear all
capture log close

/* if not already installed: install the following Stata packages in order to run this do-file:
st0085_2.pkg // estout package by Benn Jann
gr0059_1.pkg // coefplot package by Benn Jann
grc1leg // grc1leg package by Vince Wiggins
grstyle // grstyle package by Benn Jann
palettes // palettes package by Benn Jann
*/

****************************************************************************************************************************************************************
*set working directory to folder containing the subfolders "tables" and "figures" 

*cd " " 

****************************************************************************************************************************************************************
*set global macros
global tab = "tables/"
global fig = "figures/"

****************************************************************************************************************************************************************
*set grstyle for figures
grstyle clear
grstyle init
grstyle set plain, horizontal grid
grstyle set color s1   
grstyle set legend 4, inside nobox
****************************************************************************************************************************************************************
*import data

use master.dta, clear

********************************************************************************
*Variable generation, recoding and labeling
********************************************************************************

*indicator to identify one policy-vignette treatment observation per respondent
sort id conjoint task 
gen unique = mod(_n+5,6)==0

*recoded conjoint reciprocity variable
recode reciprocity (3=1 "Economies worldwide") (2=2 "Western economies") (1=3 "In any case"), gen(reciprocityrec) 

*policy vignette treatment levels received by respondent
gen stringency2 = .
gen reciprocity2 = . 
replace reciprocity2 = 1 if lawtreat == "Q17" | lawtreat == "Q18" | lawtreat == "Q19" 
replace stringency2 = 1 if lawtreat == "Q17" | lawtreat == "Q20" | lawtreat == "Q23" 
replace reciprocity2 = 2 if lawtreat == "Q20" | lawtreat == "Q21" | lawtreat == "Q22" 
replace stringency2 = 2 if lawtreat == "Q18" | lawtreat == "Q21" | lawtreat == "Q24" 
replace reciprocity2 = 3 if lawtreat == "Q23" | lawtreat == "Q24" | lawtreat == "Q25" 
replace stringency2 = 3 if lawtreat == "Q19" | lawtreat == "Q22" | lawtreat == "Q25" 

label define reciprocitylab 1"In any case" 2"Western economies" 3 "Economies worldwide", replace 
label values reciprocity2 reciprocitylab
label define stringencylab 1 "Round table" 2 "Public report" 3 "Liability", replace 
label values stringency2 stringencylab

*labels for policy vignette outcome battery	
label variable q26_1 "strengthens Swiss reputation"
label variable q26_2 "is good behavior"
label variable q26_3 "is expert solution"
label variable q26_4 "is costly"
label variable q26_5 "disadvantages Switzerland"
label variable q26_6 "reduces damage"
label variable q26_7 "is window-dressing"

*control variable vector to improve efficiency of policy vignette analysis by norms subgroup
global controls = "wdummy i.agegroup i.language i.region" 

*gen indicator of social and environmental concern (via pca and extraction of first component), in five quantiles
factor q60_1-q60_10 q59_11-q59_15 if unique==1, pcf factor(1) 
rotate
predict onefact 
xtile esc = onefact, nquantiles(5)

********************************************************************************
*Figure 2:
*AMCEs of conjoint choice experiment for dimensions stringency and reciprocity
********************************************************************************

eststo clear
eststo: reg policychosen ib3.reciprocity ib1.stringency if normstreatment==0, cluster(id)

coefplot  , drop(_cons) base xtitle(AMCEs) ///
yline(3.5, lpattern(dash) lcolor(gs9)) xline(0, lpattern(solid))   order(*stringency* 3.reciprocity 2.reciprocity)

graph export "$fig\Fig2.eps", replace

********************************************************************************
*Figure 3:
*Respondent evaluations of regulatory frameworks by policy components for
*subgroups not receiving the norms-treatment
********************************************************************************

eststo clear
 foreach x of varlist q26?? {
 quietly eststo `x': reg `x' i.stringency2 ib3.reciprocity2  if unique==1 & normstreatment == 0, r // 
}
 
coefplot  q26*4  , bylabel("is costly for Swiss firms") || q26*5 , bylabel("disadvantages Swiss firms") || q26*6  , bylabel("reduces damage by Swiss firms") || q26*7  , bylabel("is window-dressing") || q26*2 , bylabel("is good behavior") || q26*3  , bylabel("is expert solution") || ///
   q26*1  ,  bylabel("strengthens Swiss reputation ")  ///
 scheme(s1color) keep(*str* *rec*  ) xline(0, lpattern(solid))  byopts(style(compact) cols(1) )  xsize(1) ysize(1.5) xlabel(-.6(.2).6,  grid) ///
   grid( glstyle(minor_grid) glcolor(gray)) ytick(3.5, notick glstyle(refline) glpattern(dash) glcolor(gs9)) /// 
legend(size(small) region(lcolor(white))) base order(*stringency2* 3.reciprocity2 2.reciprocity2)
	
graph export "$fig\Fig3.eps", replace

********************************************************************************
*Figure 4:
*AMCEs for conjoint choice by subgroups of environmental and social concern
********************************************************************************

foreach v in esc {
eststo clear
eststo very_low: reg policychosen  i.stringency ib1.reciprocityrec  if `v'==1 & normstreatment == 0, cluster(id)
eststo low: reg policychosen i.stringency ib1.reciprocityrec   if `v'==2 & normstreatment == 0, cluster(id)
eststo medium: reg policychosen  i.stringency ib1.reciprocityrec   if `v'==3 & normstreatment == 0, cluster(id)
eststo high: reg policychosen  i.stringency ib1.reciprocityrec   if `v'==4 & normstreatment == 0, cluster(id)
eststo very_high: reg policychosen i.stringency ib1.reciprocityrec    if `v'==5 & normstreatment == 0, cluster(id)
}

grstyle clear
grstyle init
grstyle set plain, horizontal grid
grstyle set color s1 
grstyle set legend ,  nobox

coefplot (very_low, msymbol(Oh)) (low, msymbol(O)) (medium, msymbol(S)) (high, msymbol(Dh)) (very_high, msymbol(D)), ///
keep( *reci* *string*) byopts(style(compact) cols(1)  ) xlabel(-.2(.1).5,  grid) ///
    grid( glstyle(minor_grid) glcolor(gray)) ytick(3.5, notick glstyle(refline) glpattern(dash) glcolor(gray)) xline(0) ///
	legend(cols(5) subtitle(Concern is...) label(2 "very low") label(4 "low") label(6 "medium") label(8 "high") label(10 "very high")) base 
	
graph export "$fig\Fig4.eps", replace

********************************************************************************
*Figure 5:
*Marginal means of conjoint choice experiment for dimensions stringency and 
*reciprocity 
********************************************************************************

grstyle set color s1 
grstyle set legend 2 ,  inside nobox  


eststo clear
reg policychosen ib3.reciprocity ib1.stringency if normstreatment==0, cluster(id)
eststo one: margins ib3.reciprocity ib1.stringency , post
reg policychosen ib3.reciprocity ib1.stringency if normstreatment==1, cluster(id)
eststo two: margins ib3.reciprocity ib1.stringency, post

coefplot (one, msymbol(T)) (two, msymbol(S)) , drop(_cons) base xtitle(Marginal means) ///
yline(3.5, lpattern(dash) lcolor(gs9)) xline(0.5, lpattern(solid))  legend(order(2 "no norms treatm." 4 "norms treatm.")) order(*stringency* 3.reciprocity 2.reciprocity) name(one, replace)

eststo clear
reg policychosen (ib3.reciprocity ib1.stringency)##i.normstreatment  , cluster(id)
eststo three: margins ib3.reciprocity ib1.stringency , dydx(normstreatment) post

coefplot three,  nolabel name(two, replace) title("") xtitle(Diff. in means)  legend(off ) ///
ylabel("") yline(3.5, lpattern(dash) lcolor(gs9)) xline(0, lpattern(solid))  fxsize(20) order(*stringency* 3.reciprocity 2.reciprocity)  //  

graph combine one two , cols(2)	

graph export "$fig\Fig5.eps", replace

********************************************************************************
*Table A.1:
*Effect of norm treatment on mechanisms 
********************************************************************************

eststo clear
local i=1
foreach x of varlist q26?? {
 quietly eststo : reg `x' i.normstreatment $controls  if unique==1 // 
mean `x' if normstreatment==0 
 estat sd
 mat sd=r(sd)
 mat mean=r(mean)
estadd scalar Control_mean = mean[1,1] : est`i'
estadd scalar Control_sd = sd[1,1] : est`i'
local ++i
}

esttab using "$tab\TabA1.tex" ///
, drop(0.norms*) indicate("Controls = wdummy") ///
 keep(*treat* *cons*) se label star(+ 0.1 * 0.05 ** 0.01 *** 0.001) /// 
 replace compress stats(N r2_a  Control_mean Control_sd) b(2) se(2) ///
 nonote 
 
********************************************************************************
*Figure A.4:
* Marginal means of consequences of policy vignette for dimensions stringency 
* and reciprocity with 95% confidence intervals (robust standard errors in parentheses) by norms treatment
********************************************************************************


eststo clear

quietly foreach y in 0 1 {
foreach x of varlist q26?? {
 reg `x' i.stringency2 ib3.reciprocity2 $controls  if unique==1 & normstreatment == `y' , r // 
 eststo `x'`y' : margins ib3.reciprocity2 ib1.stringency2, post
}
}
 
coefplot  q26*4?  , bylabel("is costly for Swiss firms") || q26*5?  , bylabel("disadvantages Swiss firms") || q26*6?  , bylabel("reduces damage by Swiss firms") || ///
q26*7?  , bylabel("is window-dressing") || q26*2? , bylabel("is good behavior") || q26*3?  , bylabel("is expert solution") || (q26*10, label(Perception w/o norms treatm.) ) (q26*11, label(Perception with norms treatm.) ms(T)), bylabel("strengthens Swiss reputation ")  xtitle("                         Marginal means")   ///  
scheme(s1color) keep(*str* *rec*  ) xline(3.5, lpattern(solid) )  byopts(style(compact) cols(1) )  xsize(1) ysize(1.5) xlabel(2.25(.25)4.25,  grid) ///
grid( glstyle(minor_grid) glcolor(gray)) ytick(3.5, notick glstyle(refline) glpattern(dash) glcolor(gs9)) /// 
legend(size(small) region(lcolor(white))) name(one, replace)  order(*stringency* 3.reciprocity2 2.reciprocity2)
	
eststo clear
foreach x of varlist q26?? {
 quietly    reg `x' (ib3.reciprocity2 ib1.stringency2)##i.normstreatment $controls  if unique==1 , r  // 
 eststo `x' : margins ib3.reciprocity2 ib1.stringency2 , dydx(normstreatment) post
}

coefplot  q26*4  , bylabel("is costly for Swiss firms") || q26*5  , bylabel("disadvantages Swiss firms") || q26*6 , bylabel("red. damage by Swiss firms") || ///
q26*7 , bylabel("is window-dressing")  ||  q26*2 , bylabel("is good behavior") ||  q26*3  , bylabel("is expert solution") || q26*1, bylabel("strengthens Swiss reputation ")  xtitle("Diff. in means" " " " "  , margin(l+0 r+0 b+0.5 t+0.5))  ///
scheme(s1color) keep(*str* *rec*  ) xline(0, lpattern(solid) )  byopts(style(compact) cols(1) )  xsize(1) ysize(1.5) xlabel(-0.3(.1)0.3,  grid) ///
grid( glstyle(minor_grid) glcolor(gray)) ytick(3.5, notick glstyle(refline) glpattern(dash) glcolor(gs9)) /// 
legend(size(small) region(lcolor(white))) name(two, replace)  fxsize(30) order(*stringency* 3.reciprocity2 2.reciprocity2) ylabel("")  
	
graph combine one two, cols(2)   
gr_edit .plotregion1.graph1.legend.DragBy 0 11.62008143740405
// legend reposition
gr_edit .plotregion1.graph1.legend.DragBy -.1075933466426296 .7531534264984127
// legend reposition

graph export "$fig\FigA4.eps", replace
 
 
 
********************************************************************************
*Figure A.5:
*Subgroups effects for conjoint choice by environmental and social concern and by 
*respondents not receiving (upper panel) and receiving (lower panel) the norms 
*treatment
********************************************************************************

 
eststo clear
foreach z in 0 1 {
foreach v in esc {
eststo very_low`z': reg policychosen  i.stringency ib1.reciprocityrec  if `v'==1 & normstreatment == `z', cluster(id)
eststo low`z': reg policychosen i.stringency ib1.reciprocityrec   if `v'==2 & normstreatment == `z', cluster(id)
eststo medium`z': reg policychosen  i.stringency ib1.reciprocityrec   if `v'==3 & normstreatment == `z', cluster(id)
eststo high`z': reg policychosen  i.stringency ib1.reciprocityrec   if `v'==4 & normstreatment == `z', cluster(id)
eststo very_high`z': reg policychosen i.stringency ib1.reciprocityrec    if `v'==5 & normstreatment == `z', cluster(id)
}
}

coefplot (very_low0, msymbol(Oh))  (low0, msymbol(O))  (medium0, msymbol(S)) (high0, msymbol(Dh)) (very_high0, msymbol(D)), bylabel(No norms treatment) || very_low1  low1  medium1 high1 very_high1 , bylabel(Norms treatment) keep( *reci* *string*) byopts(title("                   AMCEs") style(compact) cols(1)  ) ///
scheme(s1color) xlabel(-.2(.1).5,  grid) ///
    grid( glstyle(minor_grid) glcolor(gray)) ytick(3.5, notick glstyle(refline) glpattern(dash) glcolor(gs9)) xline(0) base ///
	legend(region(col(white)) cols(5) subtitle(Concern is...) order(2 "very low" 4 "low" 6 "medium" 8 "high" 10 "very high")) name(one, replace) fxsize(70) 
 		
	
eststo clear
foreach z in 0 1 {		
foreach x in 1 2 3 4 5 {
reg policychosen  i.stringency ib3.reciprocityrec  if esc==`x' & normstreatment == `z', cluster(id)
eststo plot`x'`z': margins stringency reciprocityrec, post
}
}

coefplot (plot10, msymbol(Oh)) (plot20, msymbol(O)) (plot30, msymbol(S)) (plot40, msymbol(Dh)) (plot50, msymbol(D)) , bylabel(No norms treatment) || plot11 plot21 plot31 plot41 plot51 , bylabel( Norms treatment) keep( *reci* *string*) byopts(title("Marginal means") style(compact) cols(1)  ) ///
scheme(s1color) xlabel(0.3(.05)0.75,  grid) ///
    grid( glstyle(minor_grid) glcolor(gray)) ytick(3.5, notick glstyle(refline) glpattern(dash) glcolor(gs9)) xline(0.5) base   ///
	legend(region(col(white)) cols(5) subtitle(Concern is...) order(2 "very low" 4 "low" 6 "medium" 8 "high" 10 "very high")) name(two, replace) fxsize(45) ylabel("") 
 		
grc1leg  one  two, legendfrom(one)
gr_edit .plotregion1.graph1.legend.draw_view.setstyle, style(no)
// legend edits
gr_edit .plotregion1.graph2.legend.draw_view.setstyle, style(no)
// legend edits
gr_edit .legend.DragBy 1.183526813068933 13.4491683303288
// legend reposition
gr_edit .legend.subtitle.style.editstyle size(small) editcopy
// subtitle size
gr_edit .legend.plotregion1.label[1].style.editstyle size(small) editcopy
// label[1] size
gr_edit .legend.plotregion1.label[2].style.editstyle size(small) editcopy
// label[2] size
gr_edit .legend.plotregion1.label[3].style.editstyle size(small) editcopy
// label[3] size
gr_edit .legend.plotregion1.label[4].style.editstyle size(small) editcopy
// label[4] size
gr_edit .legend.plotregion1.label[5].style.editstyle size(small) editcopy
// label[5] size
gr_edit .legend.plotregion1.key[1].view.style.editstyle marker(size(small)) editcopy
// view size
gr_edit .legend.plotregion1.key[2].view.style.editstyle marker(size(small)) editcopy
// view size
gr_edit .legend.plotregion1.key[3].view.style.editstyle marker(size(small)) editcopy
// view size
gr_edit .legend.plotregion1.key[4].view.style.editstyle marker(size(small)) editcopy
// view size
gr_edit .legend.plotregion1.key[5].view.style.editstyle marker(size(small)) editcopy
// view size

graph export "$fig\FigA5.eps", replace 	// manually adjust legend for nice display

********************************************************************************
*Figure A.6:
*Subgroups effects for conjoint choice by environmental and social concern and by 
*respondents not receiving (upper panel) and receiving (lower panel) the norms 
*treatment
********************************************************************************

eststo clear

reg ratingConjoint  i.stringency ib3.reciprocity if normstreatment==0, cluster(id)
eststo no_norms_treat: margins  stringency reciprocity, post

reg ratingConjoint  i.stringency ib3.reciprocity  if normstreatment==1, cluster(id)
eststo norms_treat: margins  stringency reciprocity, post

grstyle init
grstyle set color s1
grstyle set plain, horizontal grid
grstyle set legend 11 , inside nobox  
coefplot (no_norms_treat, msymbol(T)) (norms_treat, msymbol(S)) , drop(_cons) base xtitle(Marginal means) legend(order(2 "No norms treatm." 4 "Norms treatm.") position(0) bplacement(neast) rows(2)) ///
yline(3.5, lpattern(dash) lcolor(gs9)) xline(4) xlabel(4(.25)5) order(*stringency* 3.reciprocity 2.reciprocity)

graph export "$fig\FigA6.eps", replace

*END

